﻿using System;
using System.Collections.Generic;
using NUnit.Framework;

namespace Cpuss.Tests
{

    [TestFixture]
    public class MathUtilTest
    {

        /// <summary>
        /// Check to see that the correct value is returned.
        /// </summary>
        [Test]
        public void VarianceTest()
        {
            var actual = new List<double> {4, 7, 10};

            Assert.AreEqual(6, actual.Variance());
        }

        /// <summary>
        /// Check to see that the correct value is returned when the series is empty.
        /// </summary>
        [Test]
        public void VariancEmptySeriesTest()
        {
            var actual = new List<double>();

            Assert.AreEqual(0, actual.Variance());
        }

        /// <summary>
        /// Check to see that the correct exception is thrown when the series is null.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void VarianceSeriesNullTest()
        {
            List<double> actual = null;

            actual.Variance();
        }

        /// <summary>
        /// Check to see that the correct exception is thrown when the series is null.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void VarianceIntSeriesNullTest()
        {
            List<int> actual = null;

            actual.Variance();
        }

        /// <summary>
        /// Check to see that the correct mean value is returned.
        /// </summary>
        [Test]
        public void MeanTest()
        {
            var actual = new List<int> {4, 7, 10};

            Assert.AreEqual(7, actual.Mean());
        }

        /// <summary>
        /// Check to see the correct value is returned when the collection is empty.
        /// </summary>
        [Test]
        public void MeanEmptySeriesTest()
        {
            var actual = new List<int>();

            Assert.AreEqual(0, actual.Mean());
        }

        /// <summary>
        /// Check to see that the correct exception is thrown when the series is null.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void MeanSeriesNullTest()
        {
            List<int> actual = null;

            actual.Mean();
        }

        /// <summary>
        /// Check to see that the correct exception is thrown when the series is null.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void MeanDoubleSeriesNullTest()
        {
            List<double> actual = null;

            actual.Mean();
        }

    }

}
